#pragma once
#include "context.hh"
#include <glm/vec3.hpp>
#include <list>

namespace gl
{
	struct scene
	{
		struct cube
		{
			glm::vec3 pos;
			glm::vec3 fcolor;	//   fill color
			glm::vec3 bcolor;	// border color

			cube(glm::vec3 const& pos, glm::vec3 const& color)
				: pos{pos}, fcolor{color*0.5f}, bcolor{color} {}

			bool contain(glm::vec3 const& point) const;
			void render() const;
			void operator()() const { render(); }
		};

		// TODO: use multiset, sort by cube.pos.z
		using cube_list = std::list<cube>;

		static constexpr int x_range = 12;
		static constexpr int y_range = 14;
		static constexpr int z_range = 16;

		void render(context& ctx) const;
		void operator()(context& ctx) const { render(ctx); }

		void update(glm::vec3 const& cam);
		bool collide(glm::vec3 const& cam) const;

	private:
		cube_list cubes;
		glm::vec3 last_cam;

		void generate(float x, float y, float z);
	};
}

